﻿using System.Text;
using MovieModel.Model;

namespace MovieBuddy.MovieUtils
{
    public static class DescriptionUtils
    {
        public static string ShortMovieDescription(Movie movie)
        {
            var sb = new StringBuilder();
            if (movie.Year != null) sb.Append(movie.Year + " - ");
            if (movie.Runtime != null) sb.Append(movie.Runtime + " min - ");
            if (movie.PlayCount != null) sb.Append(movie.PlayCount + " plays - ");
            if (!string.IsNullOrEmpty(movie.Description))
            {
                sb.Append(movie.Description);
                if (!movie.Description.EndsWith(".")) sb.Append(".");
                sb.Append("  ");
            }
            if (movie.People != null)
            {
                bool first = true;
                foreach (var part in movie.People)
                {
                    if (!first) sb.Append(", ");
                    first = false;
                    sb.Append(part.Person);
                }
            }
            return sb.ToString();
        }
    }
}
